<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">

<ui:composition>
	<h:form id="form">
		<a4j:queue requestDelay="500" ignoreDupResponses="true"/>

		<h:panelGrid columns="2" columnClasses="top , top">
			<rich:extendedDataTable value="#{peopleBean.itemsDataModel}"
				var="record" id="table" style="width: 580px; height: 290px;"
				sortMode="#{peopleBean.sortMode}"
				sortPriority="#{peopleBean.sortPriorities}"
				selectionMode="#{peopleBean.selectionMode}"
				selection="#{peopleBean.selection}" rows="50"
				>

				<a4j:ajax execute="@form" event="selectionchange"
					listener="#{peopleBean.selectionListener}"
					render=":peopleBean_selectiontable" />

            	<f:facet name="noData">
                	Nothing found
            	</f:facet>

				<ui:include src="/templates/include/jpaColumn.xhtml">
					<ui:param name="bean" value="#{peopleBean}" />
					<ui:param name="beanData" value="#{record.firstName}" />
					<ui:param name="property" value="firstName" />
					<ui:param name="headerText" value="#{bundle['entities.person.firstName']}" />
					<ui:param name="textFilterRendered" value="true"/>
					<ui:param name="columnWidth" value="210px;" />
				</ui:include>

				<ui:include src="/templates/include/jpaColumn.xhtml">
					<ui:param name="bean" value="#{peopleBean}" />
					<ui:param name="beanData" value="#{record.lastName}" />
					<ui:param name="property" value="lastName" />
					<ui:param name="headerText" value="#{bundle['entities.person.lastName']}" />
					<ui:param name="textFilterRendered" value="true"/>
					<ui:param name="columnWidth" value="210px;" />
				</ui:include>

				<ui:include src="/templates/include/jpaColumn.xhtml">
					<ui:param name="bean" value="#{peopleBean}" />
					<ui:param name="beanData" value="#{record.birthDate}" />
					<ui:param name="property" value="birthDate" />
					<ui:param name="headerText" value="#{bundle['entities.person.birthDate']}" />
					<ui:param name="columnWidth" value="155px;" />
				</ui:include>
			</rich:extendedDataTable>
			<h:panelGroup layout="block" style="width:500px">
				<rich:panel>
					<f:facet name="header">
						<h:outputText value="#{bundle['windows.sortSelectionModes.title']}" />
					</f:facet>
					<h:panelGrid columns="2">
						<!--
						<h:outputText value="#{bundle['windows.sortSelectionModes.sortMode']}" />
						<rich:select value="#{peopleBean.sortMode}" defaultLabel="#{bundle['windows.sortSelectionModes.selectionMode.Multi']}">
							<a4j:ajax execute="@form" event="selectitem" render=":table"/>

							<f:selectItem itemLabel="#{bundle['windows.sortSelectionModes.sortMode.Single']}" itemValue="single" />
							<f:selectItem itemLabel="#{bundle['windows.sortSelectionModes.sortMode.Multi']}" itemValue="multiple" />
						</rich:select>
						-->

						<h:outputText value="#{bundle['windows.sortSelectionModes.selectionMode']}" />
						<rich:select value="#{peopleBean.selectionMode}" defaultLabel="#{bundle['windows.sortSelectionModes.selectionMode.Multi']}">
							<a4j:ajax execute="@form" event="selectitem" render=":table"/>

							<f:selectItem itemLabel="#{bundle['windows.sortSelectionModes.selectionMode.Single']}" itemValue="single" />
							<f:selectItem itemLabel="#{bundle['windows.sortSelectionModes.selectionMode.Multi']}" itemValue="multiple" />
							<f:selectItem itemLabel="#{bundle['windows.sortSelectionModes.selectionMode.None']}" itemValue="none" />
						</rich:select>
					</h:panelGrid>
				</rich:panel>
			    <rich:panel>
			        <f:facet name="header">
			            <h:outputText value="#{bundle['windows.entities.person.Actions']}"></h:outputText>
			        </f:facet>
			        	<a4j:commandButton action="#{peopleBean.removeSelected}" value="#{bundle['entities.removeSelectedRecords']}" render=":table, :peopleBean_selectiontable">
							<a4j:ajax execute="@form" event="click" render=":table, :peopleBean_selectiontable"/>
						</a4j:commandButton>
			    </rich:panel>
			    <rich:panel>
			        <f:facet name="header">
			            <h:outputText value="#{bundle['windows.entities.person.NewEntity']}"></h:outputText>
			        </f:facet>
			        <h:panelGrid columns="2">
			            <h:outputText value="#{bundle['entities.person.firstName']}"/>
			            <rich:inplaceInput defaultLabel="click to enter your firstname" value="#{peopleBean.person.firstName}" />
			            <h:outputText value="#{bundle['entities.person.lastName']}"/>
			            <rich:inplaceInput defaultLabel="click to enter your lastname" value="#{peopleBean.person.lastName}" />
			            <h:outputText value="#{bundle['entities.person.birthDate']}"/>
			             <rich:calendar value="#{peopleBean.newPersonCalendar.selectedDate}"
			                        locale="#{peopleBean.newPersonCalendar.locale}"
			                        popup="#{peopleBean.newPersonCalendar.popup}"
			                        datePattern="#{peopleBean.newPersonCalendar.pattern}"
			                        showApplyButton="#{peopleBean.newPersonCalendar.showApply}" style="width:200px"/>
			            <a4j:commandButton action="#{peopleBean.createNew}" value="#{bundle['entities.createNewRecord']}" render=":table, :peopleBean_selectiontable">
							<a4j:ajax execute="@form" event="click" render=":table, :peopleBean_selectiontable"/>
			            </a4j:commandButton>
			        </h:panelGrid>
				</rich:panel>
			</h:panelGroup>
		</h:panelGrid>

		<rich:panel>
			<f:facet name="header">
				<h:outputText value="#{bundle['windows.currentlySelected.title']}" />
			</f:facet>
			<rich:dataTable value="#{peopleBean.selectionItems}" var="sel"
				id="peopleBean_selectiontable" width="100%">
				<rich:column width="100%">
					<h:panelGrid columns="2" columnClasses="top , top" width="100%">
						<rich:panel>
							<f:facet name="header">
								<h:outputText
									value="#{bundle['windows.entities.person.Detail']}"></h:outputText>
							</f:facet>
							<h:panelGrid columns="2">
								<h:outputText value="#{bundle['entities.person.firstName']}" />
								<h:outputText value="#{sel.firstName}" />
								<h:outputText value="#{bundle['entities.person.lastName']}" />
								<h:outputText value="#{sel.lastName}" />
								<h:outputText value="#{bundle['entities.person.birthDate']}" />
								<h:outputText value="#{sel.birthDate}" />
							</h:panelGrid>
						</rich:panel>
						<h:panelGroup layout="block" style="width:100%">
							<!-- Address -->
							<rich:panel>
								<f:facet name="header">
									<h:outputText
										value="#{bundle['windows.entities.address.Detail']}"></h:outputText>
								</f:facet>
								<h:panelGrid columns="2" width="100%">
									<h:outputText value="#{bundle['entities.address.country']}" />
									<h:outputText value="#{sel.address.country}" />
									<h:outputText value="#{bundle['entities.address.city']}" />
									<h:outputText value="#{sel.address.city}" />
									<h:outputText value="#{bundle['entities.address.streetName']}" />
									<h:outputText value="#{sel.address.streetName}" />
									<h:outputText value="#{bundle['entities.address.zip']}" />
									<h:outputText value="#{sel.address.zip}" />
								</h:panelGrid>
							</rich:panel>
							<!-- Training -->
							<rich:panel>
								<f:facet name="header">
									<h:outputText value="#{bundle['windows.entities.training.Detail']}"></h:outputText>
								</f:facet>
									<rich:dataTable var="entry" value="#{sel.trainingsAsList}" width="100%">
										<f:facet name="header">
											<rich:columnGroup>
												<rich:column>
													<h:outputText
														value="#{bundle['entities.training.code']}"></h:outputText>
												</rich:column>
												<rich:column>
													<h:outputText
														value="#{bundle['entities.training.name']}"></h:outputText>
												</rich:column>
												<rich:column>
													<h:outputText
														value="#{bundle['entities.training.description']}"></h:outputText>
												</rich:column>
												<rich:column>
													<h:outputText
														value="#{bundle['entities.training.passTimestamp']}"></h:outputText>
												</rich:column>
												<rich:column>
													<h:outputText
														value="#{bundle['entities.training.evidencePassExpiration']}"></h:outputText>
												</rich:column>
											</rich:columnGroup>
										</f:facet>
											<rich:column>
												<h:outputText value="#{entry.trainingType.code}" />
											</rich:column>
											<rich:column>
												<h:outputText value="#{entry.trainingType.name}" />
											</rich:column>
											<rich:column>
												<h:outputText value="#{entry.trainingType.description}" />
											</rich:column>
											<rich:column>
												<h:outputText value="#{entry.passTimestamp}" />
											</rich:column>
											<rich:column>
												<h:outputText value="#{entry.evidencePassExpiration}" />
											</rich:column>
									</rich:dataTable>
							</rich:panel>
							<!-- Medical examination -->
							<rich:panel>
								<f:facet name="header">
									<h:outputText value="#{bundle['windows.entities.medExam.Detail']}"></h:outputText>
								</f:facet>
									<rich:dataTable var="entry" value="#{sel.medicalExaminationsAsList}" width="100%">
										<f:facet name="header">
											<rich:columnGroup>
												<rich:column>
													<h:outputText
														value="#{bundle['entities.medExam.code']}"></h:outputText>
												</rich:column>
												<rich:column>
													<h:outputText
														value="#{bundle['entities.medExam.name']}"></h:outputText>
												</rich:column>
												<rich:column>
													<h:outputText
														value="#{bundle['entities.medExam.description']}"></h:outputText>
												</rich:column>
												<rich:column>
													<h:outputText
														value="#{bundle['entities.medExam.passedTimestamp']}"></h:outputText>
												</rich:column>
											</rich:columnGroup>
										</f:facet>
											<rich:column>
												<h:outputText value="#{entry.medicalExaminationType.code}" />
											</rich:column>
											<rich:column>
												<h:outputText value="#{entry.medicalExaminationType.name}" />
											</rich:column>
											<rich:column>
												<h:outputText value="#{entry.medicalExaminationType.description}" />
											</rich:column>
											<rich:column>
												<h:outputText value="#{entry.passedTimestamp}" />
											</rich:column>
									</rich:dataTable>
							</rich:panel>
						</h:panelGroup>
					</h:panelGrid>
				</rich:column>
			</rich:dataTable>
		</rich:panel>
	</h:form>
</ui:composition>

</html>
